﻿package mortal.game.view.group.cellRenderer
{
    import Message.Public.*;
    import com.greensock.layout.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class GroupApplyCellRenderer extends GCellRenderer
    {
        private var _sGroupOper:SGroupOper;
        private var _teamName:GTextFiled;
        private var _career:GTextFiled;
        private var _level:GTextFiled;
        private var _guildName:GTextFiled;
        private var _power:GTextFiled;
        private var _agreeBtn:GButton;
        private var _rejectBtn:GButton;

        public function GroupApplyCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:* = GlobalStyle.textFormatBai;
            _loc_1.align = AlignMode.CENTER;
            this._teamName = UIFactory.gTextField("", -22, 0, 160, 20, this, _loc_1);
            this._career = UIFactory.gTextField("", 129, 0, 100, 20, this, _loc_1);
            this._level = UIFactory.gTextField("", 253, 0, 100, 20, this, _loc_1);
            this._guildName = UIFactory.gTextField("", 411, 0, 100, 20, this);
            _loc_1 = GlobalStyle.textFormatChen;
            _loc_1.align = AlignMode.CENTER;
            this._power = UIFactory.gTextField("", 503, 0, 100, 20, this, _loc_1);
            this._agreeBtn = UIFactory.gButton(Language.getString(30230), 648, -1, 40, 22, this);
            this._agreeBtn.configEventListener(MouseEvent.CLICK, this.agreeHandler);
            this._rejectBtn = UIFactory.gButton(Language.getString(30231), 689, -1, 40, 22, this);
            this._rejectBtn.configEventListener(MouseEvent.CLICK, this.rejectHandler);
            this.pushUIToDisposeVec(UIFactory.bg(0, 25, 760, 1, this, ImagesConst.SplitLine));
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._teamName.dispose(param1);
            this._career.dispose(param1);
            this._level.dispose(param1);
            this._guildName.dispose(param1);
            this._power.dispose(param1);
            this._agreeBtn.dispose(param1);
            this._rejectBtn.dispose(param1);
            this._teamName = null;
            this._career = null;
            this._level = null;
            this._guildName = null;
            this._power = null;
            this._agreeBtn = null;
            this._rejectBtn = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function agreeHandler(event:MouseEvent) : void
        {
            var _loc_2:* = new Array();
            var _loc_3:* = new SGroupOper();
            _loc_3.fromEntityId = Cache.instance.role.entityInfo.entityId;
            _loc_3.toEntityId = this._sGroupOper.fromEntityId;
            _loc_3.fromPlayer = new SPublicPlayer();
            _loc_3.fromPlayer.guildId = new SEntityId();
            _loc_3.fromPlayer.copyId = new SEntityId();
            _loc_3.fromPlayer.entityId = Cache.instance.role.entityInfo.entityId;
            _loc_3.type = EGroupOperType._EGroupOperTypeAgree;
            _loc_3.uid = this._sGroupOper.uid;
            _loc_2.push(_loc_3);
            Dispatcher.dispatchEvent(new DataEvent(EventName.GroupApplyReplyOper, _loc_2));
            return;
        }// end function

        private function rejectHandler(event:MouseEvent) : void
        {
            var _loc_2:* = new Array();
            var _loc_3:* = new SGroupOper();
            _loc_3.fromEntityId = Cache.instance.role.entityInfo.entityId;
            _loc_3.toEntityId = this._sGroupOper.fromEntityId;
            _loc_3.fromPlayer = new SPublicPlayer();
            _loc_3.fromPlayer.guildId = new SEntityId();
            _loc_3.fromPlayer.copyId = new SEntityId();
            _loc_3.fromPlayer.entityId = Cache.instance.role.entityInfo.entityId;
            _loc_3.type = EGroupOperType._EGroupOperTypeReject;
            _loc_3.uid = this._sGroupOper.uid;
            _loc_2.push(_loc_3);
            Dispatcher.dispatchEvent(new DataEvent(EventName.GroupApplyReplyOper, _loc_2));
            return;
        }// end function

        private function setCareer(param1:int) : void
        {
            this._career.text = GameDefConfig.instance.getCarrer(param1);
            return;
        }// end function

        private function setGuildName() : void
        {
            this._guildName.text = this._sGroupOper.fromPlayer.guildName ? (this._sGroupOper.fromPlayer.guildName) : (Language.getString(35301));
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            this._sGroupOper = param1.data;
            if (this._sGroupOper)
            {
                this.setCareer(this._sGroupOper.fromPlayer.career);
                this.setGuildName();
                this._teamName.text = this._sGroupOper.fromPlayer.name;
                this._level.text = this._sGroupOper.fromPlayer.level.toString();
                this._power.text = this._sGroupOper.fromPlayer.combat.toString();
            }
            return;
        }// end function

    }
}
